/*
 * @Author       : NaN 353362604@qq.com
 * @Date         : 2023-07-05 14:30:39
 * @LastEditTime : 2023-07-05 15:14:51
 * @LastEditors  : NaN 353362604@qq.com
 * @FilePath     : \AdminStration\src\Common\Router\MenuNav\FirstLevel\ProjectSetUp.jsx
 * @Description  :
 */
import { API_LIST } from '../../../Api/Api'
import { commonTableList } from '../Common/common'
import { MapPositioning, OpenTwoRouter } from '../Common/options'
import { OrganizationIdentityLevel } from '../Common/Conversion'

export const ProjectSetUp = async ({ url, OptionsEvent, Permission, actionRef }) => {
    let data = {
        pageSize: 10,
        params: { pageIndex: 1 },
        get: API_LIST([4])[`getOrganizationIdentityLevel`],
        columns: [
            commonTableList.uuid,
            {
                dataIndex: 'selfOrganizationUuid',
                title: '组织机构',
                valueType: 'select',
                valueEnum: await OrganizationIdentityLevel(4),
                width: 300,
                hideInAdded: true,
                hideInModify: true,
                hideInTable: true,
            },
            { ...commonTableList.tableName, title: '项目名称', width: 500, hideInSearch: true },
            { ...commonTableList.code, rules: true, hideInSearch: true },
            { ...commonTableList.sortId, rules: true, hideInSearch: true },
            commonTableList.createUserName,
            commonTableList.createTime,
            commonTableList.updateUserName,
            commonTableList.updateTime,
            {
                title: '操作',
                valueType: 'systemOperation',
                fixed: 'right',
                width: 320,
                hideInSearch: true,
                hideInAdded: true,
                hideInModify: true,
                render: (_, record) => {
                    return [
                        Permission.findIndex(v => v.uuid === '83bba2dc-912d-4590-93ce-e415cd6613d1') !== -1 && (
                            <MapPositioning
                                key="map"
                                title="项目定位"
                                OptionsEvent={OptionsEvent}
                                data={{
                                    record,
                                    url: 'posProjectInfo',
                                    field: 'projectCompanyCoordinate',
                                }}
                            />
                        ),
                        Permission.findIndex(v => v.uuid === '1a451da2-df8b-4084-84c9-0774a11b5d70') !== -1 && (
                            <OpenTwoRouter
                                key="TwoOne"
                                title="付费测算"
                                modal="TableList"
                                OptionsEvent={OptionsEvent}
                                other={{
                                    page: 'ProjectSetUpPayment',
                                    Permission,
                                    actionRef,
                                    oneData: record,
                                    header: data.columns,
                                }}
                            />
                        ),
                        Permission.findIndex(v => v.uuid === '7b7cf898-8e89-4f0f-9222-39d8dbd6cb6d') !== -1 && (
                            <OpenTwoRouter
                                key="TwoTwo"
                                title="项目阶段"
                                modal="TableList"
                                OptionsEvent={OptionsEvent}
                                other={{
                                    page: 'ProjectSchedule',
                                    Permission,
                                    actionRef,
                                    oneData: record,
                                    header: data.columns,
                                }}
                            />
                        ),
                    ]
                },
            },
        ],
    }

    return data
}
